package org.eenie.kdassistant.hooker;

import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebView;

import com.alibaba.fastjson.JSON;

import org.eenie.kdassistant.utils.ApplicationUtil;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URLDecoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import static de.robv.android.xposed.XposedHelpers.callStaticMethod;

/**
 * Created by Eenie on 2017/8/1.
 * Email: eeniework@gmail.com
 * Des:
 */

public class XposedInit implements IXposedHookLoadPackage {


    String PKG_NAME_XZ = "com.yto.receivesend";
    String PKG_NAME_ZZB = "com.geenk.zto.sys";
    String PKG_NAME_ST = "com.kuaibao.skuaidi";


    Application XZ_APP;
    Application ZZT_APP;
    Application ST_APP;


    Object QrcodeSignInActivityInstance;
    Method sendNoMethod;
    Method sendReqMethod;
    Object callbackObj;


    Object httpInstance;


    Object ZZT_INSTANCE;
    Method ZZT_SEND_METHOD;

    Object ST_INSTANCE;
    Method ST_SEND_METHOD;


//    List<String> xzNo = new ArrayList<>();
//    List<String> zztNo = new ArrayList<>();
//    List<String> stNo = new ArrayList<>();


    BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            XposedBridge.log(intent.getIntExtra("method", 0) + " onReceive pkg = " + context.getPackageName());
            switch (intent.getIntExtra("method", 0)) {
                case 0:

                    try {
                        Object object = XposedHelpers.callStaticMethod(context.getClass().getClassLoader().loadClass("com.yto.walker.f.p"), "j", new Class[]{String.class}, intent.getStringExtra("express"));

                        XposedBridge.log(String.format("收到 = %s\n转换 = %s", intent.getStringExtra("express"), object.toString()));


                    } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                    }


//                    ApplicationUtil.openXingZhe(context);
                    break;
                case 1:
                    ApplicationUtil.openZZT(context);
                    break;
                case 2:
                    ApplicationUtil.openST_DJ(context);
                    break;
                case 3:
                    XposedBridge.log("接收到单号 = " + intent.getStringExtra("express"));

                    xzAddNum(httpInstance, intent.getStringExtra("express"));

//                    sendExpressNo(QrcodeSignInActivityInstance, sendNoMethod, intent.getStringExtra("express"));
                    break;

                case 4:
                    XposedBridge.log("接收到单号 = " + intent.getStringExtra("express"));
                    sendExpressNo(ZZT_INSTANCE, ZZT_SEND_METHOD, intent.getStringExtra("express"));
                    break;
                case 5:
                    XposedBridge.log("接收到单号 = " + intent.getStringExtra("express"));
                    sendExpressNo(ST_INSTANCE, ST_SEND_METHOD, intent.getStringExtra("express"));
                    break;

                case 100:
//                    xzAddNum(httpInstance, intent.getStringExtra("express"));
                    break;
            }


        }
    };


    @Override
    public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        if (lpparam.packageName.equals(PKG_NAME_XZ)) {
            hookXingZhe(lpparam);
        } else if (lpparam.packageName.equals(PKG_NAME_ZZB)) {
            hookZZB(lpparam);
        } else if (lpparam.packageName.equals(PKG_NAME_ST)) {
            hookST(lpparam);
        }
    }


    private void hookXingZhe(final XC_LoadPackage.LoadPackageParam lpparam) throws ClassNotFoundException {
        XposedBridge.log("hook success = " + lpparam.packageName);
//        XposedHelpers.findAndHookMethod("com.yto.walker.activity.WelComeActivity", lpparam.classLoader, "a", lpparam.classLoader.loadClass("com.courier.sdk.common.resp.CheckVersionResp"), new XC_MethodHook() {
//
//
//            @Override
//            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
//                //不能通过Class.forName()来获取Class ，在跨应用时会失效
////                Class c = lpparam.classLoader.loadClass("com.yto.walker.activity.WelComeActivity");
////                Field field=c.getDeclaredField("l");
////                field.setAccessible(true);
//                //param.thisObject 为执行该方法的对象，在这里指MainActivity
////                Application textView= (Application) field.get(param.thisObject);
//
//
//                Activity activity = (Activity) param.thisObject;
//                XZ_APP = activity.getApplication();
//                IntentFilter intentFilter = new IntentFilter();
//                intentFilter.addAction("com.wrbug.xposeddemo.xz");
//                XZ_APP.registerReceiver(mBroadcastReceiver, intentFilter);
//            }
//        });
        XposedHelpers.findAndHookMethod("com.yto.walker.FApplication", lpparam.classLoader, "onCreate", new XC_MethodHook() {


            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                //不能通过Class.forName()来获取Class ，在跨应用时会失效
//                Class c = lpparam.classLoader.loadClass("com.yto.walker.activity.WelComeActivity");
//                Field field=c.getDeclaredField("l");
//                field.setAccessible(true);
                //param.thisObject 为执行该方法的对象，在这里指MainActivity
//                Application textView= (Application) field.get(param.thisObject);

                XZ_APP = (Application) param.thisObject;
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction("com.wrbug.xposeddemo.xz");
                XZ_APP.registerReceiver(mBroadcastReceiver, intentFilter);

                Class httpCls = lpparam.classLoader.loadClass("com.yto.walker.activity.d.b");
                httpInstance = httpCls.newInstance();


                sendReqMethod = httpInstance.getClass().getMethod("a", int.class, String.class, Object.class, Map.class, lpparam.classLoader.loadClass("com.frame.walker.e.a"));


            }
        });

//        com.frame.walker.b
        XposedHelpers.findAndHookMethod("com.frame.walker.b.b", lpparam.classLoader, "a", String.class, String.class, new XC_MethodHook() {

            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("params1 = " + param.args[0]);
                XposedBridge.log("params2 = " + param.args[1]);


            }

            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {


                XposedBridge.log("res = " + param.getResult().toString());
            }


        });


        XposedHelpers.findAndHookMethod("com.frame.walker.b.a", lpparam.classLoader, "a", String.class, String.class, new XC_MethodHook() {

            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("data src = " + param.args[0]);
                XposedBridge.log("data key = " + param.args[1]);


            }

            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {


                XposedBridge.log("data res = " + param.getResult().toString());
            }


        });


        XposedHelpers.findAndHookMethod("com.yto.walker.activity.c.f", lpparam.classLoader, "a", String.class, String.class, Date.class, new XC_MethodHook() {

            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("params1 = " + param.args[0]);
                XposedBridge.log("params2 = " + param.args[1]);
                XposedBridge.log("params3 = " + ((Date) param.args[2]).getTime());


            }

            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {


                XposedBridge.log("res = " + param.getResult().toString());


            }


        });


        XposedHelpers.findAndHookMethod("com.yto.walker.activity.QrcodeSignInActivity", lpparam.classLoader, "a", String.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                String expressNo = param.args[0].toString();
//                if (!xzNo.contains(String.valueOf(expressNo))) {
//                xzNo.add(String.valueOf(expressNo));
                Intent intent = new Intent();
                intent.setAction("com.wrbug.xposeddemo.express");
                intent.putExtra("express", expressNo);
                intent.putExtra("src", "行者");
                Context context = (Context) param.thisObject;
                context.sendBroadcast(intent);


//                }
            }

        });


        //获取扫描成功的单号执行的方法，方便调用
        XposedHelpers.findAndHookMethod("com.yto.walker.activity.QrcodeSignInActivity", lpparam.classLoader, "b", new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

                QrcodeSignInActivityInstance = param.thisObject;


                Class c = lpparam.classLoader.loadClass("com.yto.walker.activity.QrcodeSignInActivity");
                sendNoMethod = c.getDeclaredMethod("a", String.class);
                sendNoMethod.setAccessible(true);
            }

        });


        //订单添加成功的回调
        XposedHelpers.findAndHookMethod("com.yto.walker.activity.QrcodeSignInActivity", lpparam.classLoader, "d", String.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                String expressNo = param.args[0].toString();
                XposedBridge.log("单号添加成功 = " + expressNo);
                Context context = (Context) param.thisObject;
//                ProviderUtil.updateState(context, expressNo, 3, "行者 - 上传成功");
            }

        });

//
//        //拦截toast调用
//        XposedHelpers.findAndHookMethod("com.yto.walker.f.p", lpparam.classLoader, "a", Context.class, String.class, new XC_MethodHook() {
//            @Override
//            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//                String expressNo = param.args[1].toString();
//                XposedBridge.log("dialog = " + expressNo);
//            }
//        });


        //拦截
        XposedHelpers.findAndHookMethod("com.yto.walker.activity.d.a", lpparam.classLoader, "a", Integer.class, Object.class, Map.class, String.class, String.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                Integer params1 = (int) param.args[0];

                Object params2 = param.args[1];

                Map params3 = (Map) param.args[2];

                String params4 = (String) param.args[3];

                String params5 = (String) param.args[4];


                XposedBridge.log("加密前 = \n" + String.format(" %s \n %s \n %s\n %s\n %s", params1, params2 == null ? "null" : JSON.toJSONString(params2), JSON.toJSONString(params3), params4, params5));
                Object buildObj = param.getResult();
                Object bodyObj = XposedHelpers.callMethod(buildObj, "build");
                Field field = bodyObj.getClass().getDeclaredField("encodedValues");
                field.setAccessible(true);
                List<String> names = (List<String>) field.get(bodyObj);
                XposedBridge.log(String.format("加密后 = \n k = %s \n s = %s", names.get(0), names.get(1)));

//                String k = XposedHelpers.callMethod(bodyObj, "name", new Class[]{int.class}, 0).toString();
//
//                String s = XposedHelpers.callMethod(bodyObj, "value", new Class[]{int.class}, 0).toString();

//
//                FormBody.Builder builder = null;
//                builder.build().value(0);


//                XposedBridge.log(String.format(" k = %s \n s = %s", k, s));
            }
        });


        //拦截网络请求加密前参数
//        XposedHelpers.findAndHookMethod("com.yto.walker.activity.d.b", lpparam.classLoader, "a", int.class, String.class, Object.class, Map.class, lpparam.classLoader.loadClass("com.frame.walker.e.a"), new XC_MethodHook() {
//            @Override
//            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//
//                int params1 = (int) param.args[0];
//                String params2 = (String) param.args[1];
//                Object params3 = param.args[2];
//                Map params4 = (Map) param.args[3];
//
//                if (params2.equals("0411") && callbackObj == null) {
//                    callbackObj = param.args[4];
//                }
//
//
//
//                XposedBridge.log("加密前 = "+String.format(" param %s \n %s \n %s\n %s", params1, params2, params3 == null ? "null" : params3.toString(), JSON.toJSONString(params4)));
//            }
//        });


//        //拦截网络请求加密后参数
//        XposedHelpers.findAndHookMethod("com.yto.walker.activity.d.b", lpparam.classLoader, "a", String.class, String.class, Object.class, Map.class, lpparam.classLoader.loadClass("com.frame.walker.e.a"), new XC_MethodHook() {
//            @Override
//            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//
//                String params1 = (String) param.args[0];
//                String params2 = (String) param.args[1];
//                Object params3 = param.args[2];
//                Map params4 = (Map) param.args[3];
//
//                XposedBridge.log("加密后 = "+String.format(" param encode %s \n %s \n %s\n %s", params1, params2, params3 == null ? "null" : params3.toString(), JSON.toJSONString(params4)));
//
//            }
//        });


        XposedHelpers.findAndHookMethod("com.courier.sdk.utils.GsonUtil", lpparam.classLoader, "getBean", String.class, Class.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                String expressNo = param.args[0].toString();

                XposedBridge.log("网络msg = " + expressNo);
            }
        });


    }

    private void hookZZB(final XC_LoadPackage.LoadPackageParam lpparam) throws ClassNotFoundException {
        XposedBridge.log("hook success = " + lpparam.packageName);
        XposedHelpers.findAndHookMethod("com.zto.ztohand.mvp.view.SplashActivity", lpparam.classLoader, "initView", Bundle.class, new XC_MethodHook() {


            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                Activity activity = (Activity) param.thisObject;
                ZZT_APP = activity.getApplication();
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction("com.wrbug.xposeddemo.zzt");
                ZZT_APP.registerReceiver(mBroadcastReceiver, intentFilter);
            }

            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                //不能通过Class.forName()来获取Class ，在跨应用时会失效
//                Class c = lpparam.classLoader.loadClass("com.yto.walker.activity.WelComeActivity");
//                Field field=c.getDeclaredField("l");
//                field.setAccessible(true);
                //param.thisObject 为执行该方法的对象，在这里指MainActivity
//                Application textView= (Application) field.get(param.thisObject);


            }
        });

//        XposedHelpers.findAndHookMethod("com.zto.ztohand.mvp.other.ui.activity.delivery.DeliveryActivity", lpparam.classLoader, "b", lpparam.classLoader.loadClass("com.zto.ztohand.mvp.other.data.bean.d"), new XC_MethodHook() {
//            @Override
//            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//                Object res = param.args[0];
//                String num = "";
//
//
//                XposedBridge.log(JSON.toJSONString(res));
//
//
////                num = res.getClass().getDeclaredMethod("getText").invoke(res).toString();
////                Intent intent = new Intent();
////                intent.setAction("com.wrbug.xposeddemo.express");
////                intent.putExtra("express", num);
////                intent.putExtra("src", "申通");
////                Context context = (Context) param.thisObject;
////                context.sendBroadcast(intent);
//            }
//
//        });
        XposedHelpers.findAndHookMethod("com.zto.ztohand.mvp.other.ui.activity.delivery.DeliveryActivity", lpparam.classLoader, "a", lpparam.classLoader.loadClass("com.zto.ztohand.mvp.other.data.bean.d"), new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("here a");


            }

        });


        XposedHelpers.findAndHookMethod("com.zto.ztohand.web.e", lpparam.classLoader, "shouldOverrideUrlLoading", WebView.class, String.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("here zzt = " + param.args[1]);

            }

        });


        //回调
        XposedHelpers.findAndHookMethod("com.zto.ztohand.mvp.other.ui.activity.delivery.DeliveryActivity", lpparam.classLoader, "onStart", new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("here start");

//                ZZT_INSTANCE = param.thisObject;

                Class c = lpparam.classLoader.loadClass("com.zto.ztohand.mvp.other.ui.activity.delivery.DeliveryActivity");
                Field field = c.getDeclaredField("b");
                field.setAccessible(true);
                Object bField = field.get(param.thisObject);

                ZZT_INSTANCE = bField;
                ZZT_SEND_METHOD = bField.getClass().getMethod("a", String.class);
                ZZT_SEND_METHOD.setAccessible(true);

            }

        });


        XposedHelpers.findAndHookMethod("com.zto.ztohand.mvp.other.ui.activity.delivery.DeliveryActivity", lpparam.classLoader, "b", lpparam.classLoader.loadClass("com.zto.ztohand.mvp.other.data.bean.d"), new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("here b");


            }

        });
        XposedHelpers.findAndHookMethod("com.zto.ztohand.mvp.other.ui.activity.delivery.DeliveryActivity", lpparam.classLoader, "b", List.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("here b list");


            }

        });
        XposedHelpers.findAndHookMethod("com.zto.ztohand.mvp.other.ui.activity.delivery.DeliveryActivity", lpparam.classLoader, "c", List.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("here c list");


            }

        });
        XposedHelpers.findAndHookMethod("com.zto.ztohand.web.client.ZTOClient", lpparam.classLoader, "loginResult", String.class, String.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("ZTOClient1 " + param.args[0]);
                XposedBridge.log("ZTOClient2 " + param.args[1]);


            }

        });
    }

    private void hookST(final XC_LoadPackage.LoadPackageParam lpparam) throws ClassNotFoundException {
        XposedBridge.log("hook success = " + lpparam.packageName);
        XposedHelpers.findAndHookMethod("com.kuaibao.skuaidi.activity.SplashActivityNew", lpparam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {


            }

            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                Activity activity = (Activity) param.thisObject;
                ST_APP = activity.getApplication();
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction("com.wrbug.xposeddemo.st");
                ST_APP.registerReceiver(mBroadcastReceiver, intentFilter);
            }
        });

        XposedHelpers.findAndHookMethod("com.kuaibao.skuaidi.qrcode.E3ScanActivity", lpparam.classLoader, "handleDecode", lpparam.classLoader.loadClass("com.google.zxing.Result"), Bitmap.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                Object res = param.args[0];
                String num = "";
                num = res.getClass().getDeclaredMethod("getText").invoke(res).toString();

//                if (!stNo.contains(String.valueOf(num))) {
//                stNo.add(num);
                Intent intent = new Intent();
                intent.setAction("com.wrbug.xposeddemo.express");
                intent.putExtra("express", num);
                intent.putExtra("src", "申通");
                Context context = (Context) param.thisObject;
                context.sendBroadcast(intent);
//                }


            }

        });


        XposedHelpers.findAndHookMethod("com.kuaibao.skuaidi.util.z", lpparam.classLoader, "toMD5", String.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                Object res = param.args[0];
                XposedBridge.log("toMD5 src = " + res.toString());

            }


            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("toMD5 res = " + param.getResult().toString());
            }
        });


        //HOOK添加订单的方法
        XposedHelpers.findAndHookMethod("com.kuaibao.skuaidi.sto.etrhee.activity.EthreeInfoScanActivity", lpparam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                ST_INSTANCE = param.thisObject;
                Class c = lpparam.classLoader.loadClass("com.kuaibao.skuaidi.sto.etrhee.activity.EthreeInfoScanActivity");
                ST_SEND_METHOD = c.getDeclaredMethod("a", String.class);
                ST_SEND_METHOD.setAccessible(true);


            }
        });
        //HOOK添加订单成功的回调方法
        XposedHelpers.findAndHookMethod("com.kuaibao.skuaidi.sto.etrhee.activity.EthreeInfoScanActivity", lpparam.classLoader, "onRequestSuccess", String.class, String.class, String.class, String.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

                XposedBridge.log("arg1 = " + param.args[0]);
                XposedBridge.log("arg2 = " + param.args[1]);
                XposedBridge.log("arg3 = " + param.args[2]);
                XposedBridge.log("arg4 = " + param.args[3].toString());


            }
        });
    }


    private void sendExpressNo(Object object, Method method, String expressNo) {
        try {
            method.invoke(object, expressNo);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }


    private void xzAddNum(Object instance, String express) {

        AnalogFormParams(instance.getClass().getClassLoader(), express);

        TestEncode(instance.getClass().getClassLoader());

//        try {
//            Object paramReq = instance.getClass().getClassLoader().loadClass("com.courier.sdk.packet.req.DispatchReq")
//                    .newInstance();
//            paramReq.getClass().getMethod("setExpressNo", String.class).invoke(paramReq, express);
//            paramReq.getClass().getMethod("setIsCheck", Byte.class).invoke(paramReq, Byte.valueOf((byte) 1));
//            paramReq.getClass().getMethod("setAuxOpCode", String.class).invoke(paramReq, "NEW");
////            Class clz = Class.forName("com.frame.walker.e.a");
//            sendReqMethod.invoke(instance, 3, "1001", paramReq, null, callbackObj);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

    }


    private void AnalogFormParams(ClassLoader loader, String express) {

        try {
//            Object reqObj = XposedHelpers.findClass("com.courier.sdk.packet.CRequestBody", loader).newInstance();
            Map<String, String> extMap = new HashMap<>();
            extMap.put("latitude", "31.208335");
            extMap.put("device", "860162035890117");
            extMap.put("phoneModel", "Redmi Note 3");
            extMap.put("longitude", "121.478309");
            extMap.put("phoneBrand", "Xiaomi");

//            String ver = (String) XposedHelpers.callStaticMethod(loader.loadClass("com.yto.walker.b.a"), "a");

            Object paramReq = loader.loadClass("com.courier.sdk.packet.req.DispatchReq").newInstance();
            paramReq.getClass().getMethod("setExpressNo", String.class).invoke(paramReq, express);
            paramReq.getClass().getMethod("setIsCheck", Byte.class).invoke(paramReq, Byte.valueOf((byte) 1));
            paramReq.getClass().getMethod("setAuxOpCode", String.class).invoke(paramReq, "NEW");


            Object buildObj = callStaticMethod(loader.loadClass("com.yto.walker.activity.d.a"), "a",
                    new Class[]{Integer.class, Object.class, Map.class, String.class, String.class},
                    92, paramReq, extMap, "1001", "90d46ed77a284116816082a6bb389678");


            Object bodyObj = XposedHelpers.callMethod(buildObj, "build");
            Field field = bodyObj.getClass().getDeclaredField("encodedValues");
            field.setAccessible(true);
            List<String> names = (List<String>) field.get(bodyObj);

            XposedBridge.log(String.format("http params \n k = %s \n s = %s", URLDecoder.decode(names.get(0), "UTF-8"), URLDecoder.decode(names.get(1), "UTF-8")));

        } catch (Exception e) {
            e.printStackTrace();
        }


    }


    private void TestEncode(ClassLoader loader) {

        try {
            String aesStr = XposedHelpers.callStaticMethod(loader.loadClass("com.frame.walker.b.a"), "a", new Class[]{String.class, String.class}, "123456", "9048").toString();
            String hexStr = new String((byte[]) XposedHelpers.callStaticMethod(loader.loadClass("org.a.a.a.a.a"), "a", new Class[]{byte[].class}, aesStr.getBytes("utf-8")));
            XposedBridge.log(String.format("aesStr = %s\nhexStr = %s", aesStr, hexStr));
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
